<template>
    <div>
        <el-dialog title="修改" :visible.sync="visible">
            <el-form :model="student">
                <el-form-item label="姓名" :label-width="formLabelWidth">
                    <el-input
                        v-model="student.name"
                        autocomplete="off"
                    ></el-input>
                </el-form-item>
                <el-form-item label="年龄" :label-width="formLabelWidth">
                    <el-input
                        v-model="student.age"
                        autocomplete="off"
                    ></el-input>
                </el-form-item>
                <el-form-item label="性别" :label-width="formLabelWidth">
                    <el-radio-group v-model="student.gender">
                        <el-radio label="男">男</el-radio>
                        <el-radio label="女">女</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="setUpdateVisible(false)">取 消</el-button>
                <el-button type="primary" @click="handleClick"
                    >确 定</el-button
                >
            </div>
        </el-dialog>
    </div>
</template>

<script>
import { update } from "../../services/student";
import {mapState,mapMutations} from "vuex";
export default {
    data() {
        return {
            formLabelWidth: '120px'
        };
    },
    computed:{
      visible:{
        get(){
          return this.updateVisible;
        },
        set(visible){
            this.setUpdateVisible(visible);
        }
      },
      ...mapState('student',['updateVisible','student'])
    },
    methods: {
        async handleClick() {
            // this.visible = false;
            this.setUpdateVisible(false);
            await update(this.student);
            this.$emit("show");
        },
        ...mapMutations('student',['setUpdateVisible']),
    },
};
</script>

<style>
</style>